{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "d00fc083",
   "metadata": {
    "papermill": {
     "duration": 0.002622,
     "end_time": "2022-10-26T08:27:02.102770",
     "exception": false,
     "start_time": "2022-10-26T08:27:02.100148",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# sparksql-interactive"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "645dc2c4",
   "metadata": {
    "papermill": {
     "duration": 0.004143,
     "end_time": "2022-10-26T08:27:02.111011",
     "exception": false,
     "start_time": "2022-10-26T08:27:02.106868",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "This component creates a container image for running interactive SparkSQL queries on the CLI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4e59fe38",
   "metadata": {
    "papermill": {
     "duration": 2.308259,
     "end_time": "2022-10-26T08:27:04.423791",
     "exception": false,
     "start_time": "2022-10-26T08:27:02.115532",
     "status": "completed"
    },
    "scrolled": true,
    "tags": []
   },
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "os.environ['create_image']='True'\n",
    "os.environ['repository']='docker.io/romeokienzler'\n",
    "os.environ['version']='0.3'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dde74e6c",
   "metadata": {},
   "outputs": [],
   "source": [
    "if bool(os.environ.get('create_image',False)):\n",
    "    docker_file=\"\"\"\n",
    "    FROM debian\n",
    "    RUN apt update && apt install -y python3-pip procps default-jre\n",
    "    RUN pip install ipython nbformat pyspark\n",
    "    \"\"\"\n",
    "    with open(\"Dockerfile\", \"w\") as text_file:\n",
    "        text_file.write(docker_file)\n",
    "\n",
    "    !docker build -t claimed-sparksql-interactive:`echo $version` .\n",
    "    !docker tag claimed-sparksql-interactive:`echo $version` `echo $repository`/claimed-sparksql-interactive:`echo $version`\n",
    "    !docker push `echo $repository`/claimed-sparksql-interactive:`echo $version`\n",
    "    !rm Dockerfile"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.1"
  },
  "papermill": {
   "default_parameters": {},
   "duration": 5.223558,
   "end_time": "2022-10-26T08:27:05.697642",
   "environment_variables": {},
   "exception": null,
   "input_path": "/home/romeokienzler/gitco/claimed/component-library/input/input-url.ipynb",
   "output_path": "/home/romeokienzler/gitco/claimed/component-library/input/input-url.ipynb",
   "parameters": {},
   "start_time": "2022-10-26T08:27:00.474084",
   "version": "2.3.3"
  },
  "vscode": {
   "interpreter": {
    "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
